#! /bin/bash

set -e

pr_info () {
    echo -e "\033[0;32m$*\033[0m"
}

cd_bbb () {
    if [ -z $BBB_WS ]; then
        echo "No env: BBB_WS"
        exit
    fi
    cd $BBB_WS
}


# switch bbb base dir
cd_bbb

pr_info "[clones] uboot ..."
git clone -b v2024.07 --depth 1 https://source.denx.de/u-boot/u-boot.git u-boot

pr_info "[switch] master"
cd u-boot/
git switch -c master
cd - > /dev/null

pr_info "[clones] linux ..."
git clone -b v6.6 --depth 1 https://gitee.com/mirrors/linux_old1.git linux
#git clone -b v6.6 --depth 1 https://github.com/torvalds/linux.git linux

pr_info "[switch] master"
cd linux/
git switch -c master
cd - > /dev/null
